package com.sxpi.chapter02.controller;

import com.sxpi.chapter02.pojo.User;
import com.sxpi.chapter02.service.order.IOrderService;
import com.sxpi.chapter02.service.user.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 董伟豪
 * @Date: 2023/2/4 12:53
 */
@RestController
@Slf4j
public class OrderController {

    @Autowired
    private IUserService userService;

    @Autowired
    private IOrderService orderService;

    @PostMapping("/order/buy")
    public String buyCourse(@RequestParam("courseId")Long courseId){
        User user = userService.getUserById(1L) ;
        log.info("您购买的课程是：{},购买的用户是:");
        return orderService.buyCourse(user, courseId);
    }
}
